# 函数的返回值
def calc(a, b):
    print(a + b)


# 调用
calc(10, 20)            # 30
print(calc(10, 20))     # None  因为该函数打印输出的时候，就是None


def calc2(a, b):
    s = a + b
    return s    # 将s返回给函数的调用处去处理


# 调用
print(calc2(20, 20))    # 40
print('-'*30)

g_value = calc2(40, 40)     # 40+40
print(g_value)              # 80
print('-'*30)

g2_value = calc2(calc2(1, 2), 3)    # 1+2+3
print(g2_value)         # 6
print('-'*30)


# 返回值可以是多个
def get_num(num):
    s = 0           # 累加和
    odd_sum = 0     # 奇数和
    even_sum = 0    # 偶数和
    for i in range(1, num + 1):
        if i % 2 != 0:  # 说明的奇数
            odd_sum += i
        else:
            even_sum += i
        s += i
    return odd_sum, even_sum, s     # 3个值


# 调用
result = get_num(10)
print(type(result))     # <class 'tuple'>
print(result)           # (25, 30, 55)
print('-'*30)

# 解包赋值
a, b, c = get_num(10)   # 返回3个值，元组类型
print(a)                # 25
print(b)                # 30
print(c)                # 55
print('-'*30)

